package org.footballmanager.pandafootball.system.form.impl;

import lombok.Getter;
import lombok.Setter;
import org.footballmanager.pandafootball.system.domain.FootSsls;
import org.footballmanager.pandafootball.system.domain.enums.LSZT;
import org.footballmanager.pandafootball.system.form.SearchForm;
import org.springframework.util.StringUtils;
import tk.mybatis.mapper.entity.Example;

import java.io.Serializable;

@Getter
@Setter
public class FootSslsSearchForm extends SearchForm implements Serializable {
	private static final long serialVersionUID = 8090668615941861541L;
	protected String name;
    private LSZT lszt;

	public Example buildSearchCommond() {
		Example example = new Example(FootSsls.class);
		Example.Criteria criteria = example.createCriteria();
		if (!StringUtils.isEmpty(name)) {
			criteria.andLike("name", "%" + name.trim() + "%");
			Example.Criteria criteria2 = example.createCriteria();
			criteria2.andLike("bm", "%" + name.trim() + "%");
			example.or(criteria2);
		}
        if(lszt != null){
            criteria.andEqualTo("lszt", lszt);
        }
        criteria.andEqualTo("delFlag", 0);
		example.orderBy("createTime desc");
		return example;
	}

}
